package cn.edu.zut.cs.Controller;

import cn.edu.zut.cs.Business.Service;
import cn.edu.zut.cs.Model.Vehicle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class VehicleController {
    Service service;
    @RequestMapping(value = "/index.html")
    public String index(){
        return "index";
    }
    @RequestMapping(value = "/vehiclelist.html")
    public String Vehiclelist(HttpServletRequest request){

        request.getSession().setAttribute("vehilces",service.queryAll());
        return "vehiclelist";
    }
    @RequestMapping(value = "/newvehicle.html")
    public String newvehicle(){
        return "newVehicle";
    }
    @RequestMapping(value = "*insert.html")
    public String insert(HttpServletRequest request, Vehicle vehicle){
        service.insert(vehicle);
        request.getSession().setAttribute("vehicles",service.queryAll());
        return "vehiclelist";
    }
@Autowired
    public void setService(Service service) {
        this.service = service;
    }
}
